import requests
import parsel
import time
import re

old = time.time()
for page in range(1, 11):
    print(f'=========正在保存{page}页表情==============================')
    url = f'https://www.fabiaoqing.com/biaoqing/lists/page/{page}.html'
    dome = 'https://www.fabiaoqing.com/'
    resp = requests.get(url=url)
    # selector = parsel.Selector(resp.text)
    # href_list = selector.css('.tagbqppdiv a::attr(href)').getall()
    href_list = re.findall('<img class="ui image lazy" data-original="(.*?)"', resp.text)
    for href in href_list:
        # url_2 = dome + href
        # resp_2 = requests.get(url=url_2)
        # selector_2 = parsel.Selector(resp_2.text)
        # src = selector_2.css('.biaoqingpp::attr(src)').get()

        name = href.split('/')[-1]
        resp_3 = requests.get(url=href).content
        with open(f'biaoqing/{name}', mode='wb') as f:
            f.write(resp_3)

        print(f'{href}保存成功！！！！')
    print(f'========={page}页表情保存完成==============================')
new = time.time()
print('花费时间是：',new - old)

